/*
 * @Author: jianfanfan 是是是
 * @Date: 2025-09-04 16:03:13
 * @LastEditors: jianfanfan 是是是
 * @LastEditTime: 2025-09-11 09:25:24
 * @FilePath: \nest-project\src\app.module.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Module, NestModule, type MiddlewareConsumer } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PersonModule } from './person/person.module';
import { AaaModule } from './aaa/aaa.module';
import { BbbModule } from './bbb/bbb.module';
import { CccModule } from './ccc/ccc.module';
import { DddModule } from './ddd/ddd.module';
import { LogMiddleware } from './log.middleware';
import { LoginGuard } from './login.guard';
import { AaaMiddleware } from './aaa.middleware';
import { FffModule } from './fff/fff.module';
import { ZzzModule } from './zzz/zzz.module';

@Module({
  imports: [
    PersonModule,
    AaaModule,
    BbbModule.register({
      aaa: 1,
      bbb: 2,
    }),
    CccModule.register({
      aaa: 10,
      bbb: '999',
    }),
    DddModule,
    FffModule,
    ZzzModule,
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'app_service',
      useClass: AppService,
    },
    {
      provide: 'person',
      useValue: { name: 'John', age: 30 },
    },
    {
      provide: 'person2',
      useFactory: () => ({ name: 'Jane', age: 25 }),
    },
  ],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(AaaMiddleware).forRoutes('*');
  }
}
